<template>
	<view class="tabs-custom-wrap">
		<u-tabs class="tabs-inner"
			:lineColor="activeColor"
			:keyName="keyName"
			:activeStyle="{ color: activeColor, 'font-weight': 700, 'font-size':activeSize }"
			:current="active"
			:inactiveStyle="{ color: inactiveColor, 'font-size': inactiveSize }"
			:list="list"
			:lineWidth="lineWidth"
			@click="tabsChange"
		>
		<view slot="right">
			<slot name="right"></slot>
		</view>
		</u-tabs>
	</view>
</template>

<script>
	export default {
		name: 'tabs-custom',
		components: {},
		props: {
			list: {
				type: Array,
				default: ()=>{
					return []
				}
			},
			keyName: {
				type: String,
				default: ''
			},
			active: {
				type: [String, Number],
				default: 0
			},
			activeSize: {
				type: [String, Number],
				default: '32rpx'
			},
			inactiveSize: {
				type: [String, Number],
				default: '32rpx'
			},
			lineWidth: {
				type: Number,
				default: 30
			},
		},
		data() {
			return {
				globalColor: getApp().globalData.globalColor,
				activeColor: '',
				inactiveColor: ''
			};
		},
		watch: {
			globalColor: {
				handler(newVal) {
					if (newVal) {
						this.activeColor = newVal['selectedFontColor'];
						this.inactiveColor = newVal['contentFontLightColor'];
					}
				},
				deep: true,
				immediate: true
			}
		},
		computed: {
			_active: {
				get() {
					return this.active
				},
				set(val) {
					this.$emit('update:active', val)
				}
			}
		},
		mounted() {
			
		},
		methods: {
			tabsChange(e){
				this.$emit('change',e)
			}
		},
	};
</script>

<style lang="scss" scoped>
	.tabs-custom-wrap{}
	.tabs-custom-wrap /deep/.u-tabs__wrapper__nav__line{background-color: var(--selectedFontColor);}
</style>